<template>
<div class="page" data-name="home">
	<div class="navbar">
		<div class="navbar-inner">
			<div class="title sliding">{{$root.PSI.productionName}}</div>
		</div>
	</div>

	<div class="page-content">
		{{#each mainMenu}}
		<div class="block-title">{{caption}}</div>
		<div class="list">
			<ul>
				{{#each items}}
				<li><a href="{{url}}" @click="{{click}}"
					class="item-content item-link">
						<div class="item-inner">
							<div class="item-title">{{caption}}</div>
						</div>
				</a></li> {{/each}}
			</ul>
		</div>
		{{/each}}
	</div>
</div>
</template>

<script>
	return {
		methods : {
			todo : function() {
				var me = this;
				var app = me.$app;
				app.dialog.alert("本模块正在开发中");
			},
			doNothing : function() {

			},
			doLogout : function() {
				var me = this;
				var app = me.$app;
				var $$ = me.$$;

				app.dialog.confirm("请确认是否退出？", me.$root.PSI.productionName,
						function() {
							var loginURL = app.data.PSI.baseURI
									+ "H5/User/doLogout";

							app.preloader.show();

							app.request.post(loginURL, {}, function(data) {
								app.preloader.hide();
								if (data.success) {
									app.data.PSI.userIsLoggedIn = false;
									me.$router.refreshPage();
								} else {
									app.dialog.alert(data.msg);
								}
							}, function() {
								app.preloader.hide();
								app.dialog.alert("网络错误");
							}, "json");
						});
			}
		},
		data : function() {
			return {
				mainMenu : this.$route.context.mainMenu
			};
		}
	};
</script>

